PrizmDoc v12.0 - November 15, 2016
Programmatically Scrolling the Viewing Client

The ViewerControl API offers two methods for scrolling the Viewing Client:

Scroll to a Specific Target

The API enables scrolling to a specific target or location within the Viewing Client. Possible targets are:

Use the method PCCViewer.ViewerControl#scrollToAsync(target) to scroll to a specific target, as shown in the following code example:

Example
Copy Code
myViewerControl
    .scrollToAsync({
        pageNumber: 2,
        x: 500,
        y: 500
    })
    .then(
        function onFulfilled() {
            alert("The point was scrolled into view.")
        },
        function onRejected() {
            alert("Something went wrong: ")
        }
    );

The scrollToAsync method returns a PCCViewer.Promise that is fulfilled when the target is scrolled into view and has been displayed. In the onFulfilled callback is an appropriate time to take additional programmatic actions against the target (e.g. put a mark in text editing mode).

The method will attempt to center the target. If the full target does not fit at the current scale, then it will attempt to center the top left corner of the target. The method will not scroll past the bounds of the document, so in some cases it will scroll to as close to centering the target as possible.

There is also the ViewerControl#scrollTo(target) method that returns the ViewerControl object rather than a promise. It is recommended that you use scrollToAsync, unless method chaining is desired.

Scroll by a Number of Pixels

The API enables scrolling the content in the Viewing Client by a specified number of pixels. The method PCCViewer.ViewerControl#scrollBy(offsetX, offsetY) allows scrolling up, down, left, or right. Scrolling down or right is performed by passing positive offset values. Scrolling up or left is performed by passing negative offset values.

The following example demonstrates how to scroll down using this method:

Example
Copy Code
// Scroll down by 100 pixels
myViewerControl.scrollBy(0, 100);

This method will scroll content until it reaches the bounds of the document, at which point the method will stop scrolling in that direction.

When the ViewerControl is in SinglePage view mode, this method will only scroll within the current page, it will not change pages.

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback